/* GUI CONVERTED from redta.p (converter v1.75) Sat Aug 12 23:05:31 2000 */
/* redta.p - REPETITIVE                                                       */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                         */
/*N014*/ /*V8:RunMode=Character,Windows                                       */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*                */
/* REVISION: 7.3      LAST MODIFIED: 07/09/96   BY: *G1ZK* Julie Milligan     */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 9.1      LAST MODIFIED: 10/01/99   BY: *N014* Jeff Wootton       */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* myb                */


/* DOWNTIME TRANSACTION POSTING SUBPROGRAM                                    */

         {mfdeclre.i}

         define input parameter cumwo_lot as character.
         define input parameter cumwo_op as integer.
         define input parameter wkctr as character.
         define input parameter mch as character.
         define input parameter dept as character.
         define input parameter act_run_hrs as decimal.
         define input parameter eff_date as date.
         define input parameter earn_code as character.
         define input parameter down_rsn_code as character.
         define input parameter emp as character.
         define input parameter ophist_recid as recid.

         define new shared variable op_recno as recid.
         define new shared variable opgltype like opgl_type.
         define new shared variable ref like glt_ref.
         define new shared variable sf_cr_acct like dpt_lbr_acct.
/*N014*/ define new shared variable sf_cr_sub like dpt_lbr_sub.
         define new shared variable sf_cr_cc like dpt_lbr_cc.
         define new shared variable sf_dr_acct like dpt_lbr_acct.
/*N014*/ define new shared variable sf_dr_sub like dpt_lbr_sub.
         define new shared variable sf_dr_cc like dpt_lbr_cc.
         define new shared variable sf_entity like en_entity.
         define new shared variable sf_gl_amt like glt_amt.
         define variable lbr_act_amt like glt_amt.
         define variable pay_rate as decimal.
/*N014*  define variable sf_cop_acct like dpt_lbr_acct. */
/*N014*/ define variable sf_cop_acct like dpt_cop_acct.
/*N014*/ define variable sf_cop_sub like dpt_cop_sub.
         define variable sf_cop_cc like dpt_cop_cc.
         define variable sf_lbr_acct like dpt_lbr_acct.
/*N014*/ define variable sf_lbr_sub like dpt_lbr_sub.
         define variable sf_lbr_cc like dpt_lbr_cc.
/*N014* /*G1ZK*/ define variable sf_bdn_acct like dpt_lbr_acct no-undo. */
/*N014*/ define variable sf_bdn_acct like dpt_bdn_acct no-undo.
/*N014*/ define variable sf_bdn_sub like dpt_bdn_sub no-undo.
/*N014* /*G1ZK*/ define variable sf_bdn_cc like dpt_lbr_cc no-undo. */
/*N014*/ define variable sf_bdn_cc like dpt_bdn_cc no-undo.

/*N04H** {rewrsdef.i}                                                         */


         if act_run_hrs = 0 then leave.

         /*NO TRANSACTION SHOULD BE PENDING HERE USED FOR DEBUGGING*/
/*G1ZK*         {gprun.i ""gpistran.p"" "(input 1, input """")} */

         do trans:
/*GUI*/ if global-beam-me-up then undo, leave.

            find wo_mstr where wo_lot = cumwo_lot no-lock.
            find wr_route where wr_lot = wo_lot and wr_op = cumwo_op no-lock.

/*N04H**    {rewrsget.i &lot=wr_lot &op=wr_op &lock=no-lock}                  */

            find wc_mstr where wc_wkctr = wkctr and wc_mch = mch no-lock.
            find dpt_mstr where dpt_dept = dept no-lock.
            find pt_mstr where pt_part = wo_part no-lock.
            find pl_mstr where pl_prod_line = pt_prod_line no-lock.



            /*GET ACCOUNT NUMBERS*/

            find first gl_ctrl no-lock.
/*N014*/    assign
               sf_lbr_acct = gl_lbr_acct
/*N014*/       sf_lbr_sub = gl_lbr_sub
               sf_lbr_cc = gl_lbr_cc
               sf_cop_acct = gl_cop_acct
/*N014*/       sf_cop_sub = gl_cop_sub
               sf_cop_cc = gl_cop_cc.

            find si_mstr where si_site = wo_site no-lock.
            sf_entity = si_entity.

            if dpt_lbr_acct <> ""
            then assign sf_lbr_acct = dpt_lbr_acct
/*N014*/                sf_lbr_sub = dpt_lbr_sub
                        sf_lbr_cc = dpt_lbr_cc.

/*N014*/    assign
/*N014*        sf_cop_acct = dpt_cop_acc */
/*N014*/       sf_cop_acct = dpt_cop_acct
/*N014*/       sf_cop_sub = dpt_cop_sub
               sf_cop_cc = dpt_cop_cc.



            /*GET ACTUAL LABOR RATE*/

            pay_rate = wc_lbr_rate.
            find emp_mstr where emp_addr = emp no-lock no-error.

            if available emp_mstr and emp_pay_type = "HR" and emp_pay_rate <> 0 then do:
               pay_rate = emp_pay_rate.

               if earn_code <> "" then do:
                 find first ea_mstr where ea_earn = earn_code no-lock no-error.
                 if available ea_mstr then pay_rate = pay_rate * ea_rate.
               end.
            end.



            /*CALCULATE ACTUAL LABOR AMOUNT*/

/*N014*/    assign
               lbr_act_amt = pay_rate * act_run_hrs

               /*POST ACTUAL LABOR*/
               op_recno = ophist_recid
               opgltype = "LBR-2000"
               sf_dr_acct = sf_cop_acct
/*N014*/       sf_dr_sub = sf_cop_sub
               sf_dr_cc = sf_cop_cc
               sf_cr_acct = sf_lbr_acct
/*N014*/       sf_cr_sub = sf_lbr_sub
               sf_cr_cc = sf_lbr_cc
               sf_gl_amt = lbr_act_amt.
            {gprun.i ""sfopgl.p""}
/*GUI*/ if global-beam-me-up then undo, leave.


            /*UPDATE OP_HIST FIELDS*/

            find op_hist where recid(op_hist) = ophist_recid exclusive-lock.

            assign
               op__chr01 = down_rsn_code
               op_act_run = act_run_hrs
               op_dept = dept
               op_earn = earn_code
               op_lbr_cost = lbr_act_amt
               op_mch = mch
               op_wkctr = wkctr.

/*G1ZK* * * BEGIN ADD SECTION */
            /*  CALCULATE GL BURDEN                   */
            find first dpt_mstr where dpt_dept = dept no-lock no-error.
              if available dpt_mstr then do:
                if dpt_bdn_acct <> "" then do:
                  assign sf_bdn_acct = dpt_bdn_acct
/*N014*/                 sf_bdn_sub  = dpt_bdn_sub
                         sf_bdn_cc   = dpt_bdn_cc.
                end.
                if dpt_cop_acct <> "" then do:
                  assign sf_cop_acct = dpt_cop_acct
/*N014*/                 sf_cop_sub  = dpt_cop_sub
                         sf_cop_cc   = dpt_cop_cc.
                end.
              end.

/*N014*/      assign
                 sf_gl_amt = ((wc_lbr_rate * wc_bdn_pc * .01) +
                             wc_bdn_rate) * op_act_run

/*N014*       assign */
                 op_bdn_cost = op_bdn_cost + sf_gl_amt
                 sf_dr_acct  = sf_cop_acct
/*N014*/         sf_dr_sub   = sf_cop_sub
                 sf_dr_cc    = sf_cop_cc
                 sf_cr_acct  = sf_bdn_acct
/*N014*/         sf_cr_sub   = sf_bdn_sub
                 sf_cr_cc    = sf_bdn_cc
                 opgltype = "BDN-2000".
              {gprun.i ""sfopgl.p""}
/*GUI*/ if global-beam-me-up then undo, leave.

/*G1ZK* * * END ADD SECTION */

         end.
/*GUI*/ if global-beam-me-up then undo, leave.

